package cn.maihe.elg.operation.repository.entity;

import cn.maihe.framework.starter.base.sql.BaseEntity;
import cn.maihe.framework.starter.base.sql.MapperInterface;
import com.baomidou.mybatisplus.annotations.TableField;
import com.baomidou.mybatisplus.annotations.TableId;
import com.baomidou.mybatisplus.annotations.TableName;
import com.baomidou.mybatisplus.enums.FieldFill;
import com.baomidou.mybatisplus.enums.IdType;
import java.util.Date;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;

@TableName("t_org_qualification")
@NoArgsConstructor
@AllArgsConstructor
@Data
@Builder
@MapperInterface("cn.maihe.elg.operation.repository.mapper.OrgQualificationMapper")
public class OrgQualificationDO extends BaseEntity {
    /**
     * 主键
     */
    @TableId(type = IdType.ID_WORKER)
    private Long id;

    /**
     * 机构主键id
     */
    @TableField(value = "org_id")
    private Long orgId;

    /**
     * 资质类型
     */
    @TableField(value = "qualification_type")
    private String qualificationType;

    /**
     * 资质证书编号
     */
    @TableField(value = "qualification_code")
    private String qualificationCode;

    /**
     * 证书有效期
     */
    @TableField(value = "qualification_date")
    private Date qualificationDate;

    /**
     * 发证机关
     */
    @TableField(value = "offer_qualification_org")
    private String offerQualificationOrg;

    /**
     * 发证日期
     */
    @TableField(value = "offer_qualification_date")
    private Date offerQualificationDate;

    /**
     * 资质文件照片
     */
    @TableField(value = "qualification_pic")
    private String qualificationPic;

    /**
     * 创建时间
     */
    @TableField(value = "gmt_create", fill = FieldFill.INSERT)
    private Date gmtCreate;

    /**
     * 更新时间
     */
    @TableField(value = "gmt_modified", fill = FieldFill.INSERT_UPDATE)
    private Date gmtModified;

    /**
     * 创建用户
     */
    @TableField(value = "user_create", fill = FieldFill.INSERT)
    private String userCreate;

    /**
     * 更新用户
     */
    @TableField(value = "user_modified", fill = FieldFill.INSERT_UPDATE)
    private String userModified;

    public OrgQualificationVo buildVo() {
        return new OrgQualificationVo(id, orgId, qualificationType, qualificationCode, qualificationDate, offerQualificationOrg, offerQualificationDate, qualificationPic, gmtCreate, gmtModified, userCreate, userModified);
    }

    public static OrgQualificationDO of(OrgQualificationVo vo) {
        return new OrgQualificationDO(vo.getId(), vo.getOrgId(), vo.getQualificationType(), vo.getQualificationCode(), vo.getQualificationDate(), vo.getOfferQualificationOrg(), vo.getOfferQualificationDate(), vo.getQualificationPic(), vo.getGmtCreate(), vo.getGmtModified(), vo.getUserCreate(), vo.getUserModified());
    }
}
